using System;
using System.Collections;
using System.Web;
using System.Data;

namespace SystemFrameworks.Util
{
	/// <summary>
	/// Session manager.
	/// </summary>
	/// 
	[Serializable]
	public sealed class SessionHelper
	{
		private SessionHelper()
		{
		}

		#region Private Const String( name of Session )
		//save user right

		private const string USERRIGHT="UserRight";
		 
		private const string SOEID							= "SoeId";
		private const string OA_DATA						= "OAData";
		private const string IS_SIGN						="IsSign";
		private const string SPECIALFIELDENSRYPTION			="SpecialFieldEncryption";
		private const string SPECAILFIELDRIGHT				="SpecialFieldRight";
		 

		//For the search page
		private const string OA_SEARCH_DATA				    = "CriteriaSearchData";
		private const string BRANCHID						="BranchId";
		private const string PASSWORD_EXPIRED				= "PasswordExpired" ;
		private const string CONNECTIONSTRING				="ConnectString";
		private const string USERSINFO						="UsersInfo";
		private const string BACKURL						="BackUrl";
		private const string FORMACTION						="FormAction";
		private const string KEYWORD						="keyWord";
		private const string FUNCTIONID						="FunctionId";
		private const string OA_DATA_SET					="Oa_Data_Set";
		private const string USERTYPE						="UserType";

		public const string  NEW_DATA="NEW";
		public const string  EDIT_DATA="EDIT";
		public const string  DELETE_DATA="DELETE";
		public const string  FUNCTION_DATA="FUNCTION";
		public const string  REFERENCE_DATA="REFERENCE";
		public const string  MAINTAIN_DATA="MAINTAIN";
		public const string  DRAFTS_DATA="DRAFTS";
		public const string  SUBMIT_DATA="SUBMIT";
		public const string  UPDATE_DATA="UPDATE";
		public const string	 CANCEL_DATA="CANCEL";
		public const string  APPROVE_DATA="APPROVE";
		
		public const string  REJECT_DATA="REJECT";
		

		

		// Command for Action
		public const string COMMAND_PAGE			= "PAGE";
		public const string COMMAND_GO_TO			= "GOTO";
		public const string COMMAND_GO_TO_REF		= "GOTOREF";
		public const string COMMAND_APPROVE			= "APPROVE";

		#endregion
		
		



		#region OA_Data Object	
		
		
		
		
		/// <summary>
		/// CrqfData
		/// </summary>
		/// 

		public static int FunctionId
		{
			get
			{
				return (int)HttpContext.Current.Session[FUNCTIONID];
			}
			set 
			{
				HttpContext.Current.Session[FUNCTIONID]=value;
			}
		}
		public static int User_Type
		{
			get
			{
				return ( int)HttpContext.Current.Session[USERTYPE];
			}
			set 
			{
				HttpContext.Current.Session[USERTYPE]=value;
			}
		}
		public static string FormAction
		{
			get
			{
				return (string)HttpContext.Current.Session[FORMACTION];
			}
			set 
			{
				HttpContext.Current.Session[FORMACTION]=value;
			}
		}

		public static string KeyWord
		{
			get
			{
				return (string)HttpContext.Current.Session[KEYWORD];
			}
			set 
			{
				HttpContext.Current.Session[KEYWORD]=value;
			}
		}
		public static object BackUrl
		{
			get
			{
				return HttpContext.Current.Session[BACKURL];
			}
			set 
			{
				HttpContext.Current.Session[BACKURL]=value;
			}
		}

		public static object SpecialFieldRightObject
		{
			get
			{
				return HttpContext.Current.Session[SPECAILFIELDRIGHT];
			}
			set 
			{
				HttpContext.Current.Session[SPECAILFIELDRIGHT]=value;
			}
		}
		public static object SpecialFieldEncryptionObject
		{
			get
			{
				return HttpContext.Current.Session[SPECIALFIELDENSRYPTION];
			}
			set 
			{
				HttpContext.Current.Session[SPECIALFIELDENSRYPTION]=value;
			}
		}
		public static object UsersInfo
		{
			get
			{
				return HttpContext.Current.Session[USERSINFO];
			}
			set 
			{
				HttpContext.Current.Session[USERSINFO]=value;
			}
		}
		public static string ConnectString
		{
			get
			{
				string str="";
				try
				{
					str=HttpContext.Current.Session[CONNECTIONSTRING].ToString();
					return str;
				}
				catch(Exception ex)
				{
					return str;
				}
				
			}
			set
			{
				HttpContext.Current.Session[CONNECTIONSTRING]=value;

			}
		}
		public static int BranchId
		{
			get
			{
				return (int)HttpContext.Current.Session[BRANCHID];
			}
			set
			{
				HttpContext.Current.Session[BRANCHID]=value;

			}
		}
		public static string SoeId
		{
			get
			{
				return (string)HttpContext.Current.Session[SOEID];
			}
			set
			{
				HttpContext.Current.Session[SOEID]=value;

			}
		}
		public static bool IsSign
		{
			set 
			{
				HttpContext.Current.Session[IS_SIGN]=value;
			}
			get
			{
				try
				{
					
					return (bool)HttpContext.Current.Session[IS_SIGN];
				}
				catch(Exception)
				{
					return false;
				}
			}
		}
		/// <summary>
		/// Password Expired 
		/// </summary>
		public static object PasswordExpired
		{
			get
			{
				return HttpContext.Current.Session[ PASSWORD_EXPIRED ];
			}
			set
			{
				HttpContext.Current.Session[ PASSWORD_EXPIRED  ] = value;
			}
		}	

		public static object UserRightObject
		{
			get
			{
				return HttpContext.Current.Session[USERRIGHT];
			}
			set 
			{
				HttpContext.Current.Session[USERRIGHT]=value;
			}
		}
		public static DataSet OADataSet
		{
			
			get
			{
				return (DataSet)HttpContext.Current.Session[OA_DATA_SET ];
			}
			set
			{
				HttpContext.Current.Session[ OA_DATA_SET] = value;
			}			

		}
		public static object OADataObject
		{
			get
			{
				return HttpContext.Current.Session[OA_DATA ];
			}
			set
			{
				HttpContext.Current.Session[ OA_DATA ] = value;
			}			
		}

		#endregion



	}
}
